package com.example.controller;

import com.example.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/product")
public class ProductController {

    @Autowired
    private ProductService productService;

    /**
     * 把书店的书目（图书）上架到书店用户上
     * @param originalPath  书目路径
     * @param userId  书店用户id
     * @param isNewBook 是否是新书
     * @param discount 折扣
     * @return 字符串提示信息
     */
    @PutMapping("/import/bookstore")
    public String importBookstoreProduct(String originalPath,Long userId,boolean isNewBook,double discount){
        return productService.importBookstoreProduct(originalPath,userId,isNewBook,discount);
    }

    /**
     * 上架引导书
     */
    @PostMapping("/import/leadBook")
    public String importLeadBook(String originalPath,String poiPath,boolean isNewBook,double discount){
        return productService.importLeadBook(originalPath,poiPath,isNewBook,discount);
    }

    /**
     * 上架书店引导书（除了大学书店）
     */
    @PostMapping("/import/bookstore/leadBook")
    public String importBookstoreLeadBook(String poiPath,String jiaofuPath,String doubanPath,String picturePath,boolean isNewBook,double discount){
        return productService.importBookstoreLeadBook(poiPath,jiaofuPath,doubanPath,picturePath,isNewBook,discount);
    }

    /**
     * 上架大学书店引导书
     */
    @PostMapping("/import/universityBookstore/leadBook")
    public String importUniversityBookstoreLeadBook(String poiPath, String kaoyanPath, String kaogongPath, String zsbPath, String doubanPath, boolean isNewBook, double discount){
        return productService.importUniversityBookstoreLeadBook(poiPath,kaoyanPath,kaogongPath,zsbPath,doubanPath,isNewBook,discount);
    }

    /**
     * 书店固定电话、多个手机号的（没创建账号的（-3）也算）、自己手机号的用户 旧书改成新书
     */
    @PutMapping("/update/oldBookToNewBook")
    public String updateOldBookToNewBook(String poiPath){
        return productService.updateOldBookToNewBook(poiPath);
    }

    /**
     * 书店别人手机号的用户 旧书改成现金加积分，但仍是旧书
     */
    @PutMapping("/update/oldBook")
    public String updateOldBook(String poiPath){
        return productService.updateOldBook(poiPath);
    }
}
